package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqPurchaseorder;
import com.drug.mingkang.Mapper.HqPurchaseorderMapper;
import com.drug.mingkang.service.HqPurchaseorderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 原材料采购单(HqPurchaseorder)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:43
 */
@Service("hqPurchaseorderService")
public class HqPurchaseorderServiceImpl implements HqPurchaseorderService {
    @Resource
    private HqPurchaseorderMapper hqPurchaseorderMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param purchaseId 主键
     * @return 实例对象
     */
    @Override
    public HqPurchaseorder queryById(String purchaseId) {
        return this.hqPurchaseorderMapper.queryById(purchaseId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqPurchaseorder> queryAllByLimit(int offset, int limit) {
        return this.hqPurchaseorderMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqPurchaseorder 实例对象
     * @return 实例对象
     */
    @Override
    public HqPurchaseorder insert(HqPurchaseorder hqPurchaseorder) {
        this.hqPurchaseorderMapper.insert(hqPurchaseorder);
        return hqPurchaseorder;
    }

    /**
     * 修改数据
     *
     * @param hqPurchaseorder 实例对象
     * @return 实例对象
     */
    @Override
    public HqPurchaseorder update(HqPurchaseorder hqPurchaseorder) {
        this.hqPurchaseorderMapper.update(hqPurchaseorder);
        return this.queryById(hqPurchaseorder.getPurchaseId());
    }

    /**
     * 通过主键删除数据
     *
     * @param purchaseId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String purchaseId) {
        return this.hqPurchaseorderMapper.deleteById(purchaseId) > 0;
    }
}